package com.huaxia.dao.promotion;

import com.huaxia.pojo.promotion.BranchBM;

import org.apache.ibatis.annotations.Select;


import java.util.List;

/**
 * @author wangli 爱我华夏，爱我中华！
 * @date 2020/06/09 14:31
 */


public interface BranchBmMapper {

    @Select("select b.branchsname,b.branchNumBM,a.branchQuarterNumBM,round(decode(b.branchNumBM,0,0,a.branchQuarterNumBM*100/b.branchNumBM),1)branchYieldBM from\n" +
            "            (select sb.branchsname,NVL(a.num,0)branchQuarterNumBM from\n" +
            "            (select t.branchcode,count(t.branchcode)num from D_AGENT_PROVINCE_YX2 t where t.agentgrade='BM' and to_char(t.startdate,'q')=to_char(sysdate,'q') and t.agentstate='在职' group by t.branchcode)a right join SD_BRANCH sb on sb.branchcode=a.branchcode\n" +
            "        )a,\n" +
            "                (select sb.branchsname,NVL(a.num,0)branchNumBM from\n" +
            "            (select t.branchcode,count(t.branchcode)num from D_AGENT_PROVINCE_YX2 t where t.agentgrade='BM' and t.agentstate='在职' group by t.branchcode)a right join SD_BRANCH sb on sb.branchcode=a.branchcode\n" +
            "        )b where a.branchsname=b.branchsname ORDER BY a.branchQuarterNumBM desc")
    List<BranchBM> getBranchBM();
}
